package cn.tedu.dental.dental.service.impl;

import cn.tedu.dental.base.exception.ServiceException;
import cn.tedu.dental.base.response.JsonResult;
import cn.tedu.dental.base.response.StatusCode;
import cn.tedu.dental.dental.mapper.DentalMapper;
import cn.tedu.dental.dental.pojo.dto.DentalQuery;
import cn.tedu.dental.dental.pojo.dto.DentalSaveParam;
import cn.tedu.dental.dental.pojo.enity.Dental;
import cn.tedu.dental.dental.pojo.vo.DentalVO;
import cn.tedu.dental.dental.service.DentalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Slf4j
@Service
public class DentalServiceImpl implements DentalService {

    @Autowired
    private DentalMapper dentalMapper;

    @Override
    public List<DentalVO> selectDental(DentalQuery dentalQuery) {
        List<DentalVO> list = dentalMapper.selectUser(dentalQuery);
        log.debug("查询结果:{}", list);
        return list;
    }

    @Override
    public List<DentalVO> selectDentalById(Long dentalId) {
        List<DentalVO> list = dentalMapper.selectDentalById(dentalId);
        return list;
    }

    @Override
    public void saveDental(DentalSaveParam dentalSaveParam) {
        if (dentalSaveParam.getId() == null) {
            dentalMapper.insertDental(dentalSaveParam);
        }
        Dental dental = new Dental();
        BeanUtils.copyProperties(dentalSaveParam, dental);
        log.debug("保存对象:{}", dental);
        dentalMapper.updateDental(dental);
    }

    @Override
    public void deleteDental(Long dentalId) {
        dentalMapper.deleteDental(dentalId);
    }
}
